

<div id="main" role="main">
		<div class="tab-content tab-addtabs">
			<div id="content">
				<div class="row">
					<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
						 <div class="content">
							<form class="layui-form" >
								<div class="layui-form-item">
									<label class="layui-form-label">上级地区：</label>
									<div class="layui-input-block" id="pid" data-id="{$info.r_pid}">
										<input type="text" value="{$name}" disabled class="layui-input">
									</div>
								</div>

								<div class="layui-form-item">
									<label class="layui-form-label">地区名称：</label>
									<div class="layui-input-block">
										<input type="text" id="name" placeholder="地区名称" class="layui-input" value="{$info.r_name}">
									</div>
								</div>

								<div class="layui-form-item" {if condition="$info['r_type'] == 3"}style="display: none;"{/if}>
									<label class="layui-form-label">车牌前缀：</label>
									<div class="layui-input-block">
										<input type="text" id="car_prefix" placeholder="例如：粤A" class="layui-input" value="{$info.r_car_prefix|default=''}">
									</div>
								</div>
								
								<div class="layui-form-item">
									<label class="layui-form-label">地区编码：</label>
									<div class="layui-input-block">
										<input type="text" id="code" placeholder="不能为空" class="layui-input" value="{$info.r_code}">
									</div>
								</div>

								<div class="layui-form-item" {if condition="$info['r_type'] == 3"}style="display: none;"{/if}>
									<label class="layui-form-label">拼音：</label>
									<div class="layui-input-block">
										<input type="text" id="pinyin" placeholder="例如：beijing" class="layui-input" value="{$info.r_pinyin|default=''}">
									</div>
								</div>

								<div class="layui-form-item" {if condition="$info['r_type'] == 3"}style="display: none;"{/if}>
									<label class="layui-form-label">排序：</label>
									<div class="layui-input-block">
										<input type="text" id="sort" placeholder="" class="layui-input" value="{$info.r_sort|default=''}">
									</div>
								</div>
								
								<div class="layui-form-item" {if condition="$info['r_type'] == 3"}style="display: none;"{/if}>
									<label class="layui-form-label">车辆使用性质：</label>
									<div class="layui-input-block">
										<?php $array = explode(',', $info['r_car_type']);?>
										{foreach name="Car_Nature" item="v" key="k"}
											<input type="checkbox" name="car_use_type" value="{$k}" lay-skin="primary" title="{$v}" {if condition="in_array($k, $array)"}checked{/if} >
										{/foreach}
									</div>
								</div>

							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>


<script>
layui.use(['form'], function(){
var form = layui.form;
});

function doSubimt() {
	var res;
	var name        = $('#name').val();
    var pid         = $('#pid').attr('data-id');
    var code        = $('#code').val();
    var sort        = $('#sort').val();
	var pinyin  = $('#pinyin').val();
	var car_prefix = $('#car_prefix').val();
	var car_type = '';
	$('input[name="car_use_type"]:checked').each(function(){ 
		car_type += $(this).val()+','; 
	}); 

	var data    = {'id':{$info.r_id}, 'pid':pid, 'name':name, 'code':code, 'sort':sort, 'pinyin':pinyin, 'car_prefix':car_prefix, 'car_type':car_type.replace(/[,]$/,"")};
	if (name == '') {
		$.thinkmimi({Content : '地区名称不能为空！', Type:2, Align:'right', OutTime:2000});return false;
	}
	if (code == '') {
		$.thinkmimi({Content : '地区编码不能为空！', Type:2, Align:'right', OutTime:2000});return false;
	}

	$.ajax({
		type: 'post',
		data: data,
		async: false,
		url: "{:url('upd')}",
		success: function(data) {
			var array = eval('('+data+')');
			res = array;
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
				res = false;
			}
		}
	});
	return res;
}
</script>